package com.javacore.day6.player;

import com.javacore.day4.StudentDemo;

public class SortPerson {

	private String firstName, lastName;

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public int compareTo(SortPerson sortPerson){
		int compareName = firstName.compareToIgnoreCase(sortPerson.firstName);
		if (compareName==0) {
			return lastName.compareToIgnoreCase(sortPerson.lastName);
		} else {
			return compareName;
		}
	}
	public SortPerson(String firstName, String lastName){
		this.lastName = lastName;
		this.firstName = firstName;
	}
	public String toString() {
		return "Ho va Ten: " + this.lastName + " " + this.firstName + "\n";
	}
}
